package fileIO;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;


public class PrintStreamTest {
	public static void main(String[] args) throws IOException {
		test();
		test1();
		test2();
	}

	private static void test2() throws IOException {
		PrintStream errout = new PrintStream(new FileOutputStream(
				"/home/tarena/0heantai/err.txt"));
		System.setErr(errout);//错误输出重定向
		System.err.println();
		//e.printStackTrace();//调用的也是System.err.println();
	}

	private static void test1() throws IOException {
		PrintStream out = new PrintStream(new FileOutputStream(
				"/home/tarena/Desktop/1.txt"));
		System.setOut(out);// 输出重定向
		System.out.println(1511510674);
		System.out.print(new Student("mao", "male", 2));
		System.out.flush();
		System.out.close();
	}

	private static void test() throws IOException {
		PrintStream out = new PrintStream(new FileOutputStream(
				"/home/tarena/Desktop/1.txt"));
		out.println(1511510674);
		out.print(new Student("mao", "male", 2));
		out.flush();
		out.close();
	}
}
